package com;

import com.base.config.SessionFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

import javax.servlet.Filter;
@SpringBootApplication
public class Application {
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	/**
	 * 配置过滤器
	 * @return
	 */
	@Bean
	public FilterRegistrationBean someFilterRegistration() {
		FilterRegistrationBean registration = new FilterRegistrationBean();
		registration.setFilter(sessionFilter());
		registration.addUrlPatterns("*.do");
		registration.addUrlPatterns("*.htm");
		registration.addUrlPatterns("*.jsp");
		registration.setName("sessionFilter");
		registration.addInitParameter("paramName", "paramValue");
		registration.setName("sessionFilter");
		registration.setEnabled(false);//取消Filter 自动注册
		registration.setOrder(1);		//过滤器顺序
		return registration;
	}
	/**
	 * 创建一个bean
	 * @return
	 */
	@Bean(name = "sessionFilter")
	public Filter sessionFilter() {
		return new SessionFilter();

	}
}